package com.hex.liyue.lookingdatemodule.presenter;

import com.hex.liyue.commonmodule.bean.BaseBean;
import com.hex.liyue.commonmodule.manager.HttpManager;
import com.hex.liyue.commonmodule.manager.UserManager;
import com.hex.liyue.commonmodule.net.ResponseListener;
import com.hex.liyue.lookingdatemodule.bean.LookingListResultBean;

/**
 * Created by WJ on 2016/6/25.
 */
public class LookingListPresenter {
    private ILookingListView iLookListView;

    public LookingListPresenter(ILookingListView iLookListView) {
        this.iLookListView = iLookListView;
    }

    /**
     * 获取应约列表
     *
     * @param page
     * @param pageNum
     */
    public void getApplyList(int page, int pageNum) {
        iLookListView.showLod("加载中...");
        HttpManager.getInstance().applyList(UserManager.getUserId(), page, pageNum, new ResponseListener<LookingListResultBean>() {
            @Override
            public void onSuccess(LookingListResultBean lookingListResultBean) {
                iLookListView.closeLod();
                iLookListView.setAdapter(lookingListResultBean);
            }

            @Override
            public void onFailure(String responseresult) {
                iLookListView.closeLod();
                iLookListView.showT(responseresult);
            }
        });
    }

    /**
     * 完成约会
     * @param appointment_id
     * @param to_uid
     */
    public void successAppointment(String appointment_id, String to_uid) {
        iLookListView.showLod("加载中...");
        HttpManager.getInstance().successAppointment(UserManager.getUserId(), appointment_id, to_uid, new ResponseListener<BaseBean>() {
            @Override
            public void onSuccess(BaseBean baseBean) {
                iLookListView.closeLod();
                getApplyList(1,10);
            }

            @Override
            public void onFailure(String responseresult) {
                iLookListView.closeLod();
                iLookListView.showT(responseresult);
            }
        });
    }
}
